package com.quanyan.ic.mq;

import com.quanyan.ic.constants.MQConstant;
import com.quanyan.ic.middleware.mq.rocketmq.producer.AbstractProducer;
import com.quanyan.ic.middleware.mq.rocketmq.producer.SendCallbackListener;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * Created by zhuo.shi on 2017/8/23.
 */
@Component
public class SerialPortExpMessageProducer extends AbstractProducer {

    @Value("${rocketmq.nameServer}")
    private String nameServerAddress;

    private String topic = MQConstant.TOPIC_IC;
    private String tags = MQConstant.TAGS_LIGHT_SERIALPORTEXP;

    @PostConstruct
    public void start(){
        super.start();
    }

    @Override
    public String getProducerGroup() {
        return MQConstant.GROUP_SERIALPORTEXP;
    }

    @Override
    public String getNameServerAddress() {
        return nameServerAddress;
    }

    @Override
    public String getInstanceName() {
        return null;
    }

    public void syncSend(String msgId, byte[] body){
        super.syncSend(topic, tags, 0, msgId, body);
    }

    public void asyncSend(String msgId, byte[] body, SendCallbackListener listener){
        super.asyncSend(topic, tags, 0, msgId, body, listener);
    }
}
